/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.taobao.ibatiside.model.mapperv3.impl;

import java.math.BigInteger;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.taobao.ibatiside.model.mapperv3.AbstractStatement;
import org.taobao.ibatiside.model.mapperv3.CallStmtType;
import org.taobao.ibatiside.model.mapperv3.Mapperv3Package;
import org.taobao.ibatiside.model.mapperv3.ParameterMap;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Abstract Statement</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.AbstractStatementImpl#getDatabaseId <em>Database Id</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.AbstractStatementImpl#isFlushCache <em>Flush Cache</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.AbstractStatementImpl#getId <em>Id</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.AbstractStatementImpl#getParameterMap <em>Parameter Map</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.AbstractStatementImpl#getParameterType <em>Parameter Type</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.AbstractStatementImpl#getStatementType <em>Statement Type</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.AbstractStatementImpl#getTimeout <em>Timeout</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class AbstractStatementImpl extends CommonNestedStatementImpl implements AbstractStatement {
	/**
	 * The default value of the '{@link #getDatabaseId() <em>Database Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDatabaseId()
	 * @generated
	 * @ordered
	 */
	protected static final String DATABASE_ID_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getDatabaseId() <em>Database Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDatabaseId()
	 * @generated
	 * @ordered
	 */
	protected String databaseId = DATABASE_ID_EDEFAULT;

	/**
	 * The default value of the '{@link #isFlushCache() <em>Flush Cache</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isFlushCache()
	 * @generated
	 * @ordered
	 */
	protected static final boolean FLUSH_CACHE_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isFlushCache() <em>Flush Cache</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isFlushCache()
	 * @generated
	 * @ordered
	 */
	protected boolean flushCache = FLUSH_CACHE_EDEFAULT;

	/**
	 * This is true if the Flush Cache attribute has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected boolean flushCacheESet;

	/**
	 * The default value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected static final String ID_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected String id = ID_EDEFAULT;

	/**
	 * The cached value of the '{@link #getParameterMap() <em>Parameter Map</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getParameterMap()
	 * @generated
	 * @ordered
	 */
	protected ParameterMap parameterMap;

	/**
	 * The default value of the '{@link #getParameterType() <em>Parameter Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getParameterType()
	 * @generated
	 * @ordered
	 */
	protected static final String PARAMETER_TYPE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getParameterType() <em>Parameter Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getParameterType()
	 * @generated
	 * @ordered
	 */
	protected String parameterType = PARAMETER_TYPE_EDEFAULT;

	/**
	 * The default value of the '{@link #getStatementType() <em>Statement Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStatementType()
	 * @generated
	 * @ordered
	 */
	protected static final CallStmtType STATEMENT_TYPE_EDEFAULT = CallStmtType.STATEMENT;

	/**
	 * The cached value of the '{@link #getStatementType() <em>Statement Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStatementType()
	 * @generated
	 * @ordered
	 */
	protected CallStmtType statementType = STATEMENT_TYPE_EDEFAULT;

	/**
	 * This is true if the Statement Type attribute has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected boolean statementTypeESet;

	/**
	 * The default value of the '{@link #getTimeout() <em>Timeout</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTimeout()
	 * @generated
	 * @ordered
	 */
	protected static final Integer TIMEOUT_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getTimeout() <em>Timeout</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTimeout()
	 * @generated
	 * @ordered
	 */
	protected Integer timeout = TIMEOUT_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AbstractStatementImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return Mapperv3Package.Literals.ABSTRACT_STATEMENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getDatabaseId() {
		return databaseId;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDatabaseId(String newDatabaseId) {
		String oldDatabaseId = databaseId;
		databaseId = newDatabaseId;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.ABSTRACT_STATEMENT__DATABASE_ID, oldDatabaseId, databaseId));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isFlushCache() {
		return flushCache;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setFlushCache(boolean newFlushCache) {
		boolean oldFlushCache = flushCache;
		flushCache = newFlushCache;
		boolean oldFlushCacheESet = flushCacheESet;
		flushCacheESet = true;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.ABSTRACT_STATEMENT__FLUSH_CACHE, oldFlushCache, flushCache, !oldFlushCacheESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unsetFlushCache() {
		boolean oldFlushCache = flushCache;
		boolean oldFlushCacheESet = flushCacheESet;
		flushCache = FLUSH_CACHE_EDEFAULT;
		flushCacheESet = false;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.UNSET, Mapperv3Package.ABSTRACT_STATEMENT__FLUSH_CACHE, oldFlushCache, FLUSH_CACHE_EDEFAULT, oldFlushCacheESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isSetFlushCache() {
		return flushCacheESet;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getId() {
		return id;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setId(String newId) {
		String oldId = id;
		id = newId;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.ABSTRACT_STATEMENT__ID, oldId, id));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ParameterMap getParameterMap() {
		return parameterMap;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParameterMap(ParameterMap newParameterMap) {
		ParameterMap oldParameterMap = parameterMap;
		parameterMap = newParameterMap;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.ABSTRACT_STATEMENT__PARAMETER_MAP, oldParameterMap, parameterMap));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getParameterType() {
		return parameterType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParameterType(String newParameterType) {
		String oldParameterType = parameterType;
		parameterType = newParameterType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.ABSTRACT_STATEMENT__PARAMETER_TYPE, oldParameterType, parameterType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public CallStmtType getStatementType() {
		return statementType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setStatementType(CallStmtType newStatementType) {
		CallStmtType oldStatementType = statementType;
		statementType = newStatementType == null ? STATEMENT_TYPE_EDEFAULT : newStatementType;
		boolean oldStatementTypeESet = statementTypeESet;
		statementTypeESet = true;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.ABSTRACT_STATEMENT__STATEMENT_TYPE, oldStatementType, statementType, !oldStatementTypeESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unsetStatementType() {
		CallStmtType oldStatementType = statementType;
		boolean oldStatementTypeESet = statementTypeESet;
		statementType = STATEMENT_TYPE_EDEFAULT;
		statementTypeESet = false;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.UNSET, Mapperv3Package.ABSTRACT_STATEMENT__STATEMENT_TYPE, oldStatementType, STATEMENT_TYPE_EDEFAULT, oldStatementTypeESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isSetStatementType() {
		return statementTypeESet;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Integer getTimeout() {
		return timeout;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTimeout(Integer newTimeout) {
		Integer oldTimeout = timeout;
		timeout = newTimeout;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.ABSTRACT_STATEMENT__TIMEOUT, oldTimeout, timeout));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case Mapperv3Package.ABSTRACT_STATEMENT__DATABASE_ID:
				return getDatabaseId();
			case Mapperv3Package.ABSTRACT_STATEMENT__FLUSH_CACHE:
				return isFlushCache();
			case Mapperv3Package.ABSTRACT_STATEMENT__ID:
				return getId();
			case Mapperv3Package.ABSTRACT_STATEMENT__PARAMETER_MAP:
				return getParameterMap();
			case Mapperv3Package.ABSTRACT_STATEMENT__PARAMETER_TYPE:
				return getParameterType();
			case Mapperv3Package.ABSTRACT_STATEMENT__STATEMENT_TYPE:
				return getStatementType();
			case Mapperv3Package.ABSTRACT_STATEMENT__TIMEOUT:
				return getTimeout();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case Mapperv3Package.ABSTRACT_STATEMENT__DATABASE_ID:
				setDatabaseId((String)newValue);
				return;
			case Mapperv3Package.ABSTRACT_STATEMENT__FLUSH_CACHE:
				setFlushCache((Boolean)newValue);
				return;
			case Mapperv3Package.ABSTRACT_STATEMENT__ID:
				setId((String)newValue);
				return;
			case Mapperv3Package.ABSTRACT_STATEMENT__PARAMETER_MAP:
				setParameterMap((ParameterMap)newValue);
				return;
			case Mapperv3Package.ABSTRACT_STATEMENT__PARAMETER_TYPE:
				setParameterType((String)newValue);
				return;
			case Mapperv3Package.ABSTRACT_STATEMENT__STATEMENT_TYPE:
				setStatementType((CallStmtType)newValue);
				return;
			case Mapperv3Package.ABSTRACT_STATEMENT__TIMEOUT:
				setTimeout((Integer)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case Mapperv3Package.ABSTRACT_STATEMENT__DATABASE_ID:
				setDatabaseId(DATABASE_ID_EDEFAULT);
				return;
			case Mapperv3Package.ABSTRACT_STATEMENT__FLUSH_CACHE:
				unsetFlushCache();
				return;
			case Mapperv3Package.ABSTRACT_STATEMENT__ID:
				setId(ID_EDEFAULT);
				return;
			case Mapperv3Package.ABSTRACT_STATEMENT__PARAMETER_MAP:
				setParameterMap((ParameterMap)null);
				return;
			case Mapperv3Package.ABSTRACT_STATEMENT__PARAMETER_TYPE:
				setParameterType(PARAMETER_TYPE_EDEFAULT);
				return;
			case Mapperv3Package.ABSTRACT_STATEMENT__STATEMENT_TYPE:
				unsetStatementType();
				return;
			case Mapperv3Package.ABSTRACT_STATEMENT__TIMEOUT:
				setTimeout(TIMEOUT_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case Mapperv3Package.ABSTRACT_STATEMENT__DATABASE_ID:
				return DATABASE_ID_EDEFAULT == null ? databaseId != null : !DATABASE_ID_EDEFAULT.equals(databaseId);
			case Mapperv3Package.ABSTRACT_STATEMENT__FLUSH_CACHE:
				return isSetFlushCache();
			case Mapperv3Package.ABSTRACT_STATEMENT__ID:
				return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
			case Mapperv3Package.ABSTRACT_STATEMENT__PARAMETER_MAP:
				return parameterMap != null;
			case Mapperv3Package.ABSTRACT_STATEMENT__PARAMETER_TYPE:
				return PARAMETER_TYPE_EDEFAULT == null ? parameterType != null : !PARAMETER_TYPE_EDEFAULT.equals(parameterType);
			case Mapperv3Package.ABSTRACT_STATEMENT__STATEMENT_TYPE:
				return isSetStatementType();
			case Mapperv3Package.ABSTRACT_STATEMENT__TIMEOUT:
				return TIMEOUT_EDEFAULT == null ? timeout != null : !TIMEOUT_EDEFAULT.equals(timeout);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (databaseId: ");
		result.append(databaseId);
		result.append(", flushCache: ");
		if (flushCacheESet) result.append(flushCache); else result.append("<unset>");
		result.append(", id: ");
		result.append(id);
		result.append(", parameterType: ");
		result.append(parameterType);
		result.append(", statementType: ");
		if (statementTypeESet) result.append(statementType); else result.append("<unset>");
		result.append(", timeout: ");
		result.append(timeout);
		result.append(')');
		return result.toString();
	}

} //AbstractStatementImpl
